package com.lili.collection.core.fields.support;

import java.math.BigDecimal;

public class DecimalTypeSupport extends TypeSupport<BigDecimal> {

    @Override
    public BigDecimal convert(Object value) {
        if (value instanceof BigDecimal) {
            return (BigDecimal) value;
        }

        if (value instanceof String) {
            return new BigDecimal((String) value);
        }

        if (value instanceof Number) {
            return new BigDecimal(value.toString());
        }
        throw new TypeSupportConversionException(value.getClass().getSimpleName(), value);
    }

}
